package com.baizhi.service.ServiceImpl;

import com.baizhi.annotation.LogAnnotation;
import com.baizhi.dao.AlbumDtoDao;
import com.baizhi.dto.AlbumDto;
import com.baizhi.entity.Audio;
import com.baizhi.service.AlbumDtoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/4/9.
 */
@Service
public class AlbumDtoServiceImpl implements AlbumDtoService {
    @Autowired
    private AlbumDtoDao albumDtoDao;
    private Logger logger = LoggerFactory.getLogger(AlbumDtoServiceImpl.class);

    @Override
    @LogAnnotation("查询所有的专辑")
    public List<AlbumDto> selectAllAlbumDao() {
        List<AlbumDto> albumDtos = albumDtoDao.selectAllAlbumDao();
        logger.debug("查询树的所有专辑的结果---------"+String.valueOf(albumDtos));

        for (AlbumDto albumDto : albumDtos) {
            System.out.println(albumDto+"--------");
            
        }
        return albumDtos;
    }

    @Override
    public Map addAudio(Audio audio) {
        logger.debug("添加音频从前台传过来的对象----------",audio);
        Map map=new HashMap();
        try {
            albumDtoDao.addAudio(audio);
            map.put("isok",true);
        } catch (Exception e) {
            map.put("isok",false);
        }
        return  map;
    }
}
